import scrapy
from xgkInfo.items import XgkinfoItem


class XgkSpider(scrapy.Spider):
    name = 'code'
    allowed_domains = ['imyshare.com']
    start_urls = ['http://imyshare.com/']

    def parse(self, response):
        data = response.xpath('//div[@class="nav-list"]//ul/li')
        img_list = data.xpath('.//img//@src').extract()
        title_list = data.xpath('.//div[@class="nav-des"]/h3/text()').extract()
        content_list = data.xpath('.//div[@class="nav-des"]/p/text()').extract()
        lens = len(img_list)
        for i in range(0, lens):
            item = XgkinfoItem(id=i,
                               title=title_list[i],
                               content=content_list[i],
                               imgSrc=img_list[i],
                               url='xxx',
                               classes='')
            yield item
